import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class ContainerComp extends StatelessWidget {
  const ContainerComp({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: double.infinity,
      // 居中显示
      alignment: Alignment.center,
      // 背景色尽量设置在decoration中
      decoration: BoxDecoration(
        // 背景颜色
        // color: Colors.greenAccent,
        //圆角
        borderRadius: const BorderRadius.only(
          topLeft: Radius.circular(50),
          bottomRight: Radius.circular(50),
        ),
        // 边框
        border: Border.all(
          color: Colors.black54,
          width: 2,
        ),
        // 渐变
        gradient: const LinearGradient(
          colors: [Colors.lightBlue, Colors.pinkAccent],
          begin: Alignment.topLeft,
          end: Alignment.bottomRight,
        ),
        // 阴影
        boxShadow: const [
          BoxShadow(
            color: Colors.lightBlue,
            offset: Offset(5, 5),
            blurRadius: 10,
          ),
        ],
      ),
      //外边距
      // 所有方向都添加20的外边距
      // margin: const EdgeInsets.all(20),
      // 左上右下依次添加外边距
      // margin: const EdgeInsets.fromLTRB(30, 10, 20, 10),
      // 仅添加左边和顶部的外边距
      // margin: const EdgeInsets.only(left: 10, top: 30),
      // 仅添加水平方向的外边距
      // margin: const EdgeInsets.symmetric(horizontal: 10),
      // 仅添加垂直方向的外边距
      margin: const EdgeInsets.symmetric(vertical: 20),
      // 内边距
      padding: const EdgeInsets.all(20),
      child: const Text('这是一个容器组件'),
    );
  }
}
